﻿using System;

class QuadraticEquationSolver
{
    static void Main()
    {
        double a, b, c, determinant, x1, x2;
        char choice;

        Console.WriteLine("Solves quadratic equation");
         
        do
        {   
            Console.Write("Enter 'a': ");
            a = int.Parse(Console.ReadLine());
            Console.Write("Enter 'b': ");
            b = int.Parse(Console.ReadLine());
            Console.Write("Enter 'c': ");
            c = int.Parse(Console.ReadLine());
            
            determinant = (b * b) - (4 * a * c);

            if (determinant > 0)
            {
                x1 = (-b + Math.Sqrt(determinant)) / (2 * a);
                x2 = (-b - Math.Sqrt(determinant)) / (2 * a);
                Console.WriteLine("The equation has two real roots:\n{0}\n{1}", x1, x2);
            }
            else if (determinant == 0)
            {
                x1 = -b / (2 * a);
                Console.WriteLine("The equation has only one real root:\n{0}", x1);
            }
            else
            {
                Console.WriteLine("The equation has no real roots!");
            }

            Console.WriteLine();
            Console.Write("Do it again? y/n: ");
            choice = char.Parse(Console.ReadLine());

        } 
        while (choice != 'n' && choice != 'N' );
    }
}

